package com.xunji.xunji.ui.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xunji.xunji.R;

/**
 * Created by Paul on 2017/2/14.
 */

public class TracePictureImageView extends LinearLayout {
    private TextView tvTitle;
    private String title;

    public TracePictureImageView(Context context) {
        super(context);
        init(context);
    }

    public TracePictureImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
//        init(context, attrs);
    }

    public TracePictureImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
//        init(context, attrs);
    }


    private void init(Context context, AttributeSet attrs) {

        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.view_trace_image_label, null);
        tvTitle = (TextView) view.findViewById(R.id.tv_text);

        TypedArray a = context.obtainStyledAttributes(attrs,
                com.huanxiao.base.R.styleable.TracePictureImage);


        try {
            title = a.getString(com.huanxiao.base.R.styleable.TracePictureImage_title_info);
            tvTitle.setText(title);
        } finally {
            a.recycle();
        }

        addView(view);

    }

    private void init(Context context) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.view_trace_image_label, null);
        tvTitle = (TextView) view.findViewById(R.id.tv_text);
        addView(view);

    }


    public void setTitle(String title) {
        this.title = title;
        tvTitle.setText(title + "");
    }
}
